#include "uart.h"

#include "stc8g.h"

#define FOSC 11059200UL
#define BRT (65536 - FOSC / 9600 / 4)

void UART1_Isr() __interrupt 4 __using 1
{
	if (TI) {
		TI = 0;	      //清中断标志
		P3_2 = !P3_2; //测试端口
	}
	if (RI) {
		RI = 0;	      //清中断标志
		P3_3 = !P3_3; //测试端口
	}
}

void uart_initial(void)
{
	TMOD = 0x00; // UART1
	SCON = 0x50;
	AUXR |= 0x40;
	TL1 = BRT;
	TH1 = BRT >> 8;
	TR1 = 1;
	ES = 1;
	EA = 1;
}